package cn.taofuxn.sale.controller;

import cn.taofuxn.sale.controller.data.AddProducerRequest;
import cn.taofuxn.sale.controller.data.ModifyProducerRequest;
import cn.taofuxn.sale.service.ProducerService;
import cn.taofuxn.sale.service.data.base.BaseResult;
import io.swagger.annotations.Api;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * ProjectName : GeekSaleSystem
 * PackageName : cn.taofuxn.sale.controller
 * Created by Wong
 * Date: 2018/4/12
 * Time: 9:03
 */
@Api(value = "ProducerController", description = " 供应商管理")
@RestController
@RequestMapping(value = "/producer")
public class ProducerController {
	
	@Autowired
	private ProducerService m_ProducerService;
	
	@RequestMapping(value = "/getProducer", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult getProducer(int page, int pageSize) {
		return m_ProducerService.getProducer(page, pageSize);
	}
	
	@RequestMapping(value = "/addProducer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult addProducer(@Valid @RequestBody AddProducerRequest vRequest) {
		return m_ProducerService.addProducer(vRequest);
	}
	
	@RequestMapping(value = "/modifyProducer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult modifyProducer(@Valid @RequestBody ModifyProducerRequest vRequest) {
		return m_ProducerService.modifyProducer(vRequest);
	}
	
	@RequestMapping(value = "/deleteProducer", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult deleteProducer(@Valid @NotBlank @RequestParam String ProducerId) {
		return m_ProducerService.deleteProducer(ProducerId);
	}
	
}
